package com.emcom.gotour.mvc.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.emcom.gotour.mvc.message.TourCategoryMessage;
import com.emcom.gotour.mvc.view.MenuView;
import com.emcom.gotour.mvc.view.TourCategoryView;
import com.emcom.gotour.po.TourContent;
import com.emcom.gotour.service.TourContentService;
import com.emcom.gotour.vo.ChatVO;

@Controller
public class TourCategoryController {

	@Autowired
	private TourContentService tourContentService;

	@Autowired
	private MessageSource messageSource;

	@Autowired
	private ChatVO chat;

	@RequestMapping(value={"/tour_category.html"})
	public String tourCategory(HttpServletRequest request) {
		String category = request.getParameter("category");
		List<TourContent> tourContentList = tourContentService.queryAllCategoryContent(category);
		List<TourContent> popularList = tourContentService.queryPopularContent();
		TourContent ad = tourContentService.queryAd();
		TourCategoryView view = new TourCategoryView();
		view.setTitle(TourCategoryMessage.Title.value(request, messageSource));
		view.setCategory(category);
		view.setTourContentList(tourContentList);
		view.setPopularList(popularList);
		view.setAd(ad);
		view.setMenuView(new MenuView(request, messageSource));
		request.setAttribute("view", view);
		request.setAttribute("chat", chat);
		return "tour_category";
	}

}
